using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QL_tuyensinh
{
    public partial class frmDMdoituong_uutien : DevExpress.XtraEditors.XtraForm
    {
        public frmDMdoituong_uutien()
        {
            InitializeComponent();
        }

        private void frmDMdoituong_uutien_Load(object sender, EventArgs e)
        {
            var kn = new Ketnoi(frmGIAODIENDANGNHAP.stringConn);
            gridControl1.DataSource = kn.ExcuteQuery("select * from DOI_TUONG");
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            // ket noi class doi tuong
            obDMdoituong_uutien ob = new obDMdoituong_uutien();
            ob.MADOITUONG = txtdoituong.Text;
            ob.TENDOITUONG = txttendoituong.Text;
            ob.NHOMUUTIEN = txtnhomut.Text;

            // Insert database
            string a = "Insert into DOI_TUONG VALUES('" + ob.MADOITUONG + "',N'" + ob.TENDOITUONG + "',N'" + ob.NHOMUUTIEN + "')";
            var kn = new Ketnoi(frmGIAODIENDANGNHAP.stringConn);
            kn.ExcuteNonQuery(a);
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            try
            {
                if (radioButton1.Checked == true)
                {
                    txttendoituong.Enabled = true;
                    txtnhomut.Enabled = true;
                    string c1 = " select * from DOI_TUONG where DOI_TUONG = '" + txtdoituong.Text + "'";
                    var kn = new Ketnoi(frmGIAODIENDANGNHAP.stringConn);
                    gridControl1.DataSource = kn.ExcuteQuery(c1);
                }
                else if (radioButton2.Checked == true)
                {
                    txtdoituong.Enabled = true;
                    txtnhomut.Enabled = true;
                    string c2 = " select * from DOI_TUONG where TEN_DOI_TUONG = '" + txttendoituong.Text + "'";
                    var kn = new Ketnoi(frmGIAODIENDANGNHAP.stringConn);
                    gridControl1.DataSource = kn.ExcuteQuery(c2);
                }
                else if (radioButton3.Checked == true)
                {
                    txtdoituong.Enabled = true;
                    txttendoituong.Enabled = true;
                    string c3 = " select * from DOI_TUONG where NHOM_UT = '" + txtnhomut.Text + "'";
                    var kn = new Ketnoi(frmGIAODIENDANGNHAP.stringConn);
                    gridControl1.DataSource = kn.ExcuteQuery(c3);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}